<template>
  <div class="login-page">
    <div class="login-background">
      <div class="login-left"></div>
      <div class="login-right"></div>
    </div>
    <div class="login-container">
      <a-card title="基于大模型的医学检测智能生成系统" class="login-card">
        <a-form
          :model="formState"
          name="login"
          @finish="onFinish"
          autocomplete="off"
          layout="vertical"
        >
          <a-form-item
            name="username"
            :rules="[{ required: true, message: '请输入用户名!' }]"
          >
            <a-input v-model:value="formState.username" placeholder="用户名" size="large">
              <template #prefix>
                <user-outlined />
              </template>
            </a-input>
          </a-form-item>

          <a-form-item
            name="password"
            :rules="[{ required: true, message: '请输入密码!' }]"
          >
            <a-input-password v-model:value="formState.password" placeholder="密码" size="large">
              <template #prefix>
                <lock-outlined />
              </template>
            </a-input-password>
          </a-form-item>

          <a-form-item>
            <div class="login-option-row">
              <a-checkbox v-model:checked="formState.remember">记住我</a-checkbox>
              <a href="javascript:;">忘记密码?</a>
            </div>
          </a-form-item>

          <a-form-item>
            <a-button type="primary" html-type="submit" class="login-button" size="large" block>
              登录
            </a-button>
          </a-form-item>
        </a-form>
      </a-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
import { message } from 'ant-design-vue'
import { useRouter } from 'vue-router'

const router = useRouter()

interface FormState {
  username: string
  password: string
  remember: boolean
}

const formState = reactive<FormState>({
  username: '',
  password: '',
  remember: true,
})

const onFinish = (values: FormState) => {
  // 模拟登录成功
  message.success('登录成功！')
  // 跳转到dashboard
  router.push('/dashboard')
}
</script>

<style scoped>
.login-page {
  width: 100%;
  height: 100vh;
  position: relative;
  background-color: #f0f2f5;
  overflow: hidden;
}

.login-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.login-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, #00b96b, #16a9e0);
  opacity: 0.2;
  transform: skewX(-15deg) translateX(-30%);
}

.login-right {
  position: absolute;
  top: 0;
  right: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, #00b96b, #16a9e0);
  opacity: 0.1;
  transform: skewX(-15deg) translateX(30%);
}

.login-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 450px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  padding: 16px 8px;
}

.login-card :deep(.ant-card-head) {
  border-bottom: none;
  padding: 0 16px;
}

.login-card :deep(.ant-card-head-title) {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  padding: 24px 0 12px;
  color: #00b96b;
}

.login-card :deep(.ant-card-body) {
  padding: 24px 40px 40px;
}

.login-button {
  height: 44px;
  font-size: 16px;
  margin-top: 12px;
}

.login-option-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.login-option-row a {
  color: #00b96b;
}

@media (max-width: 576px) {
  .login-card {
    width: 90%;
    max-width: 400px;
  }
  
  .login-card :deep(.ant-card-body) {
    padding: 24px 20px 30px;
  }
}
</style> 